<template>
	<view class="msg-navbar-lay">
		<view class="user">
			<u-avatar 
			:text="getAvatar(user)" 
			shape="square" 
			bg-color="#0080FF"
			font-size='15'
			:src="user.avaUrl"
			style="float: left;"
			></u-avatar>
			<view class="school-name">
			{{school}}
			</view>
		</view>
		<view style="height: 70rpx;"></view>
	</view>
</template>

<script>
	export default {
		
		data() {
			return {
				user:{
					id:0,
					userName:'陈健华',
					avaUrl:'',
					phone:'',
					sex:0,
					signature:'',
					email:'',
					password:'',
					status:false,
				},
				school:'玉林师范学院',
			}
		},
		
		mounted(){
			this.user = uni.getStorageSync('user')
			uni.request({
				url:'http://localhost:8090/nailCampus/school/getSchool',
				method:'GET',
				header:{
					"token":uni.getStorageSync('token')
				},
				success:res=>{
					if(res.data.data!=null){
						this.school = res.data.data.schoolName
					}else{
						this.school = ''
					}
				}
			})
		},
		methods: {
			getAvatar(user){
				let text = '';
				// console.log("这是方法里边的",user);
				if(user.avaUrl == null|| user.avaUrl.length == 0){
					text = user.userName.slice(-2);
				}else{
					text = null;
				}
				return text;
			},
		},
	}
</script>

<style  lang="less" scoped>
	.msg-navbar-lay{
		.user{
			// border:1rpx solid red;
			background-color: white;
			position: fixed;
			top: 60rpx;
			left: 0;
			z-index: 99;
			width: 100%;
			padding-left: 40rpx;
			padding-top: 30rpx;
			padding-right: 30rpx;
			padding-bottom: 20rpx;
			::v-deep.u-avatar{
				float: left;
			}
		}
		.school-name {
			margin-left: 20rpx;
			line-height: 80rpx;
			font-size: 40rpx;
			font-weight: 600;
			float: left;
			width: 300rpx;
			height: 80rpx;
			// border: 1rpx solid red; 
		}
	}
	
</style>
